package com.example.studyapp

import com.android.volley.RequestQueue
import com.google.gson.JsonArray


val server_url: String= "http://81.70.247.65:8080/myweb/myservlet"
lateinit var server_queues: RequestQueue

//dataclass值
//设置数据包识别数据
enum class json_enum_DataClass {
    dataclass,  //识别属性
    login,  //登录
    logout,  //退出
    register,  //注册
    signup,  //签到
    change_username,  //修改账号
    change_password,  //修改密码
    paper_list,  //试卷列表
    paper,  //试卷
    paper_item,  //试题
    database_list,  //题库列表
    database_change,  //修改题库
    database,  //题库
    errors_list,  //错题库列表
    errors,  //错题库
    book_list,  //笔记列表
    book,  //笔记
    save_book,  //保存笔记
    test //测试包
}

enum class myqu_type{
    cho,    //选择题
    com     //填空题
}

//==================================================================================================
//通用无格式返回
data class jstruct_return_bool(
        val dataclass: String,
        val result: Boolean,
        val error: Boolean
)

//通用发送部分
data class jstruct_dataclass(
        val dataclass: String
)

//==================================================================================================
//登录部分发送，接收jstruct_return_bool
data class jstruct_login(
        val dataclass: String = "login",
        val username: String,
        val password: String,
)
//修改昵称部分发送，接收jstruct_return_bool
data class jstruct_change_username(
        val dataclass: String = "change_username",
        val username: String,
)
//修改密码部分发送，接收jstruct_return_bool
data class jstruct_change_password(
        val dataclass: String = "change_password",
        val username: String,
        val password: String
)
//退出登录部分发送，接收jstruct_return_bool
data class jstruct_logout(
        val dataclass: String = "logout",
        val username: String
)

//==================================================================================================
//试卷列表接收，发送为jstruct_dataclass
data class jstruct_paper_list(
        val dataclass: String = "paper_list",
        val listname: JsonArray,
        val length: Int,
        val error: Boolean
)
//要求试卷信息
data class jstruct_get_paper(
        val dataclass: String = "paper",
        val papername: String
)
//试卷信息接收
data class jstruct_paper_info(
        val dataclass: String = "paper",
        var papername: String,  //试卷名称
        val choice_qu_num: Int,  //选择题数量
        val completion_qu_num: Int,//填空题数量
        val error: Boolean
)
//试卷内容发送，接收
data class jstruct_paper_item_send(
        val dataclass: String = "paper_item",
        val item: Int,//题号
        val paper: String,//试卷名称
        val username: String
)
data class jstruct_paper_item(
        val dataclass: String = "paper_item",
        val text: String,    //题目
        val type: String,    //类型，选择题/填空题
        val answer: String,  //答案，/填空题
        val fanswer: JsonArray, //全部答案，适用于选择题“”
        val cho: Int,        //选择题
        val item: Int,
        val error: Boolean
)

//==================================================================================================
//题库列表接收，发送为jstruct_dataclass
data class Jstruct_database_list(
        val dataclass: String = "database_list",
        val listname: JsonArray,
        val length: Int,
        val error: Boolean
)
//修改默认题库发送，接收为jstruct_return_bool
data class jstruct_change_database(
        val dataclass: String = "database_change",
        val databse: String
)

//==================================================================================================
//错题集部分
//请求将指定题目加入用户的错题集
data class jstruct_errors_send(
        val dataclass: String = "errors",
        val papername: String,   //试卷名称
        val username: String,     //指明用户
        val item: Int,           //题号
)
//收到消息
data class jstruct_errors_receive(
        val dataclass: String = "errors",
        val result: Boolean,
        val error: Boolean
)
//获取错题集列表
data class jstruct_errors_list_send(
        val dataclass: String = "errors_list",
        val username: String     //指明用户
)
//返回信息
data class jstruct_errors_list(
        val dataclass: String = "errors",
        val listname: JsonArray, //错题对应试题集名称链表
        val timelist: JsonArray,
        val items: JsonArray,    //对应表项
        val length: Int,
        val error: Boolean
)
//==================================================================================================
//笔记部分
data class jstruct_book_list_send(
        val dataclass: String = "book_list",
        val username: String     //指明用户
)
data class jstruct_book_list(
        val dataclass: String = "book_list",
        val listname: JsonArray, //笔记列表
        val timelist: JsonArray,
        val length: Int,         //列表长度
        val error: Boolean
)
//获取笔记内容
data class jstruct_book_send(
        val dataclass: String = "book",
        val username: String,
        val index: Int   //笔记数组索引
)

data class jstruct_book_receive(
        val dataclass: String = "book",
        val username: String,
        val text: String,    //笔记内容
        val error: Boolean
)
//保存笔记
data class jstruct_book_edit_save(
        val dataclass: String = "save_book",
        val username: String,
        val text: String
)
data class jstruct_book_edit_save_ret(
        val dataclass: String = "save_book",
        val result: Boolean,
        val error: Boolean
)
//==================================================================================================
